package jgl.vajra.kingkong.part.mine.activity;

import java.util.Map;

import io.reactivex.Observable;
import jgl.vajra.kingkong.R;
import jgl.vajra.kingkong.bean.CommissionDetailsBean;
import jgl.vajra.kingkong.bean.WithdrawalRecordBean;
import jgl.vajra.kingkong.manager.AccountManager;
import jgl.vajra.kingkong.manager.IntentManager;
import jgl.vajra.kingkong.part.mine.viewModel.WithdrawalRecordViewModel;
import jgl.vajra.kingkong.widget.base.BaseListActivity;
import jgl.vajra.kingkong.widget.bean.BaseListData;
import jgl.vajra.kingkong.widget.interfaces.RefreshRecyclerLoadStatusListener;
import jgl.vajra.kingkong.widget.mvvm.factory.CreateViewModel;
import jgl.vajra.kingkong.widget.recyclerView.RefreshRecyclerNetConfig;
import jgl.vajra.kingkong.widget.utils.UIUtils;

@CreateViewModel(WithdrawalRecordViewModel.class)
public class WithdrawalRecordActivity extends BaseListActivity<WithdrawalRecordViewModel,WithdrawalRecordBean> {
    @Override
    protected String getToolbarTitle() {
        return "提现记录";
    }

    @Override
    protected RefreshRecyclerNetConfig getRefreshRecyclerNetConfig() {
        return new RefreshRecyclerNetConfig() {
            @Override
            public Observable getNetObservable(Map<String, Object> map, int action) {
                map.put("Authorization", AccountManager.getInstance().getLoginData(UIUtils.getContext()).authorization);
                map.put("transType", 4);
                return mViewModel.getWithdrawalRecordListData(map);
            }
        };
    }
    @Override
    protected int getItemLayout() {
        return R.layout.item_withdrawal_record;
    }

    @Override
    public void onItemClick(int position, WithdrawalRecordBean itemData) {
        IntentManager.toBillDetailsActivity(this,itemData.withdrawId);
    }

    @Override
    public void initView() {
        super.initView();
        mBinding.recyclerView.setIsDataObject(true);
        mBinding.recyclerView.setIsShowPageManager(true);
        mBinding.recyclerView.setRefreshLoaderMore(false, false);
        mBinding.recyclerView.setRefreshRecyclerLoadStatusListener(new RefreshRecyclerLoadStatusListener<BaseListData<WithdrawalRecordBean>>() {
            @Override
            public void onSucceed(BaseListData<WithdrawalRecordBean> data, int action) {
                mBinding.recyclerView.setRefreshLoaderMore(true, true);

                mBinding.recyclerView.requestNetObjectSuccess(data.data, action);
            }

            @Override
            public void onError(String errorInfo, int errorCode, int action) {
                super.onError(errorInfo, errorCode, action);
                //mBinding.recyclerView.requestNetError(errorInfo, errorCode);
            }
        });
        mBinding.recyclerView.firstLoad();
    }
}
